<script type="text/javascript">
$(function(){
	$("select#id").change(function () {
	var id = "";
	id = $(this).val();
	$.ajax({
			type: "GET",
			url: "<?php echo site_url('adozioni/lettere/ringraziamenti/ajax_get_lettera') ?>/"+id,
			success: function(msg){

				if (msg){
					$("form#form1 input#oggetto").val(msg.oggetto);
					$("form#form1 textarea#testo").val(msg.testo);
				}
				else
				{
					$("form#form1 input#name").val('');
					$("form#form1 textarea#testo").val('');
				}
			},
			dataType: 'json'
		});
          
		  
		  
	});
});

</script>
<h1><?php echo $title; ?></h1>
<div class="noprint">
<?php if (isset($notice) || $notice = $this->session->flashdata('notification')):?>
<p class="notice"><?php echo $notice;?></p>
<?php endif;?>




<form method='post' name="form1" id="form1" action="<?php echo site_url('adozioni/lettere/ringraziamenti/stampa') ?>" >
<label for="id"><?php echo __("Scegli lettera", $module) ?></label>
<select name="id" id="id" class="input-select">
<?php foreach($lettere as $l): ?>
<option value="<?php echo $l['id']; ?>"><?php echo $l['nome']; ?></option>
<?php endforeach; ?>
</select>

<br />
<label for="oggetto"><?php echo __("Oggetto", $module) ?></label>
<input type="text" name="oggetto" value="<?php if(isset($lettere['0']['oggetto']))  echo $lettere['0']['oggetto'] ?>" class="input-text"/>

<br />
<label for="testo"><?php echo __("Testo", $module) ?></label>
<textarea  name="testo" id="testo" class="input-textarea" ><?php if(isset($lettere['0']['testo'])) echo $lettere['0']['testo'] ?></textarea>

<br />

<input type="submit" name="buste" id="buste" value=" <?php echo __("Stampa Buste", $module) ?> " class="input-submit"/>
<input type="submit" name="lettere" id="lettere" value=" <?php echo __("Stampa Lettere", $module) ?> " class="input-submit"/>
<a href="<?php echo site_url('adozioni/lettere/ringraziamenti/visualizza') ?>" class="input-submit"><?php echo __("Annulla", $module) ?></a>